package com.sample.wanandroidx.ui.fragment

import com.google.android.material.tabs.TabLayoutMediator
import com.sample.library.util.ViewUtil
import com.sample.wanandroidx.adapter.HomeFragmentAdapter
import com.sample.wanandroidx.basic.BaseFragment
import com.sample.wanandroidx.databinding.FragmentClassificationBinding

class ClassificationFragment : BaseFragment<FragmentClassificationBinding>(FragmentClassificationBinding::inflate) {

    override fun initLazyLoad() {
        val titles = listOf("常用", "网站导航", "体系数据", "项目分类", "公众号")
        val fragments = mutableListOf(WebSiteFragment(),
            NaviFragment(),
            TreeFragment(),
            GenericListFragment.newInstance(3),
            WebSiteFragment())
        activity?.let {
            binding.pager.adapter = HomeFragmentAdapter(it, fragments)
            binding.pager.offscreenPageLimit = titles.size - 1
            val tabLayoutMediator = TabLayoutMediator(binding.tab, binding.pager) { tab, position ->
                tab.text = titles[position]
            }
            tabLayoutMediator.attach()
            ViewUtil.setViewpager2(binding.pager)
        }
    }

    override fun initialization() {
    }

}








